// const mongoose = require('mongoose')
// // 创建存储的 Schema 和 Model

// const zhengzhiSchema = new mongoose.Schema({
//   iid: { type: Number, required: true, unique: true, sparse: true },
//   question: { type: String, required: true },
//   options: {
//     optionA: { type: String },
//     optionB: { type: String },
//     optionC: { type: String },
//     optionD: { type: String },
//   },

//   answer: { type: String },
//   title: { type: String },

//   paper: { type: String },
//   image: { type: String },
//   name: { type: String },
//   content: { type: String },
// })

// const changshiSchema = new mongoose.Schema({
//   iid: { type: Number, required: true, unique: true, sparse: true },
//   question: { type: String, required: true },
//   options: {
//     optionA: { type: String },
//     optionB: { type: String },
//     optionC: { type: String },
//     optionD: { type: String },
//   },

//   answer: { type: String },
//   title: { type: String },

//   paper: { type: String },
//   image: { type: String },
//   name: { type: String },
//   content: { type: String },
// })

// const TestAdminBankDetailSchema = new mongoose.Schema({
//   zhengzhi: [zhengzhiSchema],
//   changshi: [changshiSchema],
// })

// const TestAdminDetailModel = mongoose.model('TestAdminDetailModel', TestAdminBankDetailSchema)

// module.exports = TestAdminDetailModel

//---------------------------------------------------------
const mongoose = require('mongoose')

// 基础题目 schema（复用）
const questionSchema = new mongoose.Schema({
  iid: { type: Number, required: true, unique: true },
  question: { type: String, required: true },
  options:[{
    value: String, 
    label: String,
    isCorrect:Boolean
  }

  ] ,
  answer: String,
  correctAnswer: String,
  title: String,
  paper: String,
  image: String,
  name: String,
  content: String,
})

// 分类题库 schema
const categorySchema = new mongoose.Schema({
  nid: { type: Number, required: true, unique: true },

  nickname: {
    type: String,
    required: true,
    unique: true, // 确保分类唯一
    enum: ['zhengzhi', 'changshi'], // 限定可选分类
  },
  questions: [questionSchema], // 题目列表
})

const TestAdminDetailModel = mongoose.model('TestAdminDetailModel', categorySchema)
module.exports = TestAdminDetailModel
